package org.carabiner.examples;

import java.awt.Component;

import org.carabiner.Carabiner;
import org.jmock.Mock;
import org.jmock.MockObjectTestCase;

/**
 * This is a more refined example of how to use Carabiner. This test takes
 * advantage of the AbstractCarabinerTestCase in order to clean up the test a
 * little.
 * 
 * 
 * @author Ben Rady (benrady@gmail.com)
 * @version 0.3
 */
public class Test2MyGuiControl extends MockObjectTestCase
{
  private MyGuiControl control;

  private Mock mockDataModel;

  public void setUp() throws Exception
  {
    mockDataModel = new Mock(MyDataModel.class);
    mockDataModel.expects(once()).method("getStringData").will(
        returnValue("Lobster Thermidor a Crevette"));
    mockDataModel.expects(once()).method("addListDataListener");

    control = new MyGuiControl((MyDataModel) mockDataModel.proxy());
  }

  /**
   * Shows the harness for this control
   * 
   * @param args
   *          String[]
   * @throws Exception
   */
  public static void main(String[] args) throws Exception
  {
    Test2MyGuiControl test = new Test2MyGuiControl();
    test.setUp();
    Carabiner.showHarness(test.control);
  }

  protected Component getComponent()
  {
    return control;
  }
}
